<template>
    <el-container style="height: 100vh;">
      <el-aside width="150px" style="height: 100%;">
        <el-menu default-active="1"
          class="el-menu-vertical-demo" 
          background-color="#545c64"
          text-color="#fff"
          @select="handleSelect"
        >
          <el-menu-item index="1">退出登录</el-menu-item>
          <el-menu-item index="2">用户商品浏览记录</el-menu-item>
          <el-menu-item index="3">订单管理</el-menu-item>
          <el-menu-item index="4">商品信息管理</el-menu-item>
          <el-menu-item index="5">公告发布</el-menu-item>
          <el-menu-item index="6">数据报表展示</el-menu-item>
          <el-menu-item index="7">用户管理</el-menu-item>
          <el-menu-item index="8">日志管理</el-menu-item>
        </el-menu>
      </el-aside>
  
      <el-container>
        <el-header class="header">
          <el-row align="middle" type="flex">
            <el-col :span="20">
              <div class="text" style="font-size: 23px;padding-left:45%;color:cadetblue;;">管理员-{{ globalState.username}}-你好，欢迎进入系统中心！</div>
            </el-col>
            <el-col :span="2" :offset="2">
              <div class="avatar"></div>
            </el-col>
          </el-row>
        </el-header>
  
        <el-main style="background: #f6f4f4;background-image: url(/src/assets/img/manager.jpg);opacity: 0.95;">
          <router-view/>
        </el-main>
      </el-container>
    </el-container>
  </template>
  
  <script>
  import { useRouter } from 'vue-router';
  import { globalState } from '../global.js';
  
  export default {
    name: 'UserInterface',
    setup() {
      const router = useRouter();
      
      const handleSelect = (index) => {
        switch(index) {
          case '1':
            router.push('/');
            break;
          case '2':
            router.push('/lookMes');
            break;
          case '3':
            router.push('/ordermanagement');
            break;
          case '4':
            router.push('/adminManage');
            break;
          case '5':
            router.push('/noticeManage');
            break;
          case '6':
            router.push('/productRanking');
            break;
          case '7':
            router.push('/usermanage');
            break;
          case '8':
            router.push('/logManage');
            break;
        }
      };
      
      return {
        handleSelect,
        globalState
      };
    },
  };
  </script>
  
  <style scoped>
  html, body {
    height: 100%;
    margin: 0;
  }
  .el-container {
    height: 100vh;
  }
  .el-menu-vertical-demo {
    height: 100%;
  }
  .header {
    height: 60px; 
    padding: 0 20px;
    background: #fff; 
    border-bottom: 1px solid #e4e4e4;
  }
  .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #f2f2f2;
    text-align: center;
    line-height: 40px;
    background-image: url(/public/favicon.ico);
    background-size: cover; 
  }
  .text {
    line-height: 60px; 
  }
  </style>